#pragma once
#include"../LibDGGSBase/DGGSDefine.hpp"
using namespace NNU::DGGS;
using namespace NNU::DGGS::Base;

_NNU_DGGS_BEGIN

    /// <summary>
    /// GridTIFF转换参数结构体
    /// <summary>
    struct GridTransform
    {
        int basePartition;
        int level;
        int rowOrigin;
        int colOrigin;
    };

    /// <summary>
    /// GridTIFF类，用于GridTIFF文件读写
    /// <summary>
    class GridTIFF
    {
    private:
        void **values= nullptr;                                 //属性值
        int _size=0;                                            //行列数
        int _bandCount=0;                                       //波段数
        double _noValue=noData;                                 //无效值
        DGGSDataType _dataType=DGGS_Unknown;                    //数据类型
        DGGSGridType _gridType=DGGSGridType::Unknown;           //格网类型
        DGGSElementType _elementType=DGGSElementType::Unknown;  //要素类型
        GridTransform _trans;                                   //转换参数

    public:
        /// <summary>
        /// 初始化
        /// </summary>
        GridTIFF();


        /// <summary>
        /// 释放内存
        /// </summary>
        ~GridTIFF();


        /// <summary>
        /// 保存为GridTIFF文件
        /// </summary>
        /// <param name="fileName">目标文件夹</param>
        /// <returns>是否成功</returns>
        bool saveToFile(const char* fileName);


        /// <summary>
        /// 读取GridTIFF文件
        /// </summary>
        /// <param name="fileName">目标文件夹</param>
        /// <returns>是否成功</returns>
        bool loadFromFile(const char* fileName);

        /// <summary>
        /// 读取GridTIFF文件的参数信息
        /// </summary>
        /// <param name="fileName">目标文件夹</param>
        /// <returns>是否成功</returns>
        bool getParams(const char* fileName);


        /// <summary>
        /// 获取转换参数
        /// </summary>
        /// <returns>GridTIFF转换参数</returns>
        GridTransform getTrans(){return this->_trans;}

        /// <summary>
        /// 获取行列数
        /// </summary>
        /// <returns>行列数</returns>
        int getSize(){return this->_size;}


        /// <summary>
        /// 获取无效值
        /// </summary>
        /// <returns>无效值</returns>
        double getNoValue(){return this->_noValue;}

        /// <summary>
        /// 获取波段数
        /// </summary>
        /// <returns>波段数</returns>
        int getBandCount(){return this->_bandCount;}

        /// <summary>
        /// 获取数据类型
        /// </summary>
        /// <returns>数据类型</returns>
        DGGSDataType getDataType(){return this->_dataType;}


        /// <summary>
        /// 获取要素类型
        /// </summary>
        /// <returns>要素类型</returns>
        DGGSElementType getElementType(){return this->_elementType;}

        /// <summary>
        /// 获取格网类型
        /// </summary>
        /// <returns>要素类型</returns>
        DGGSGridType getGridType(){return this->_gridType;}

        /// <summary>
        /// 获取波段值
        /// </summary>
        /// <param name="bandId">波段ID</param>
        /// <returns>波段值</returns>
        void* getBandValue(int bandId){return this->values[bandId];}

        /// <summary>
        /// 设置数据类型
        /// </summary>
        /// <param name="dataType">数据类型</param>
        void setDataType(DGGSDataType dataType){this->_dataType=dataType;}

        /// <summary>
        /// 设置要素类型
        /// </summary>
        /// <param name="dataType">要素类型</param>
        void setElementType(DGGSElementType elementType){this->_elementType=elementType;}

        /// <summary>
        /// 设置格网类型
        /// </summary>
        /// <param name="dataType">格网类型</param>
        void setGridType(DGGSGridType gridType){this->_gridType=gridType;}

        /// <summary>
        /// 设置波段值
        /// </summary>
        /// <param name="bandValue">波段值</param>
        /// <param name="bandId">波段ID</param>
        void setBandValue(void*&bandValue,int bandId){this->values[bandId]=bandValue;}

        /// <summary>
        /// 设置转换参数
        /// </summary>
        /// <param name="trans">转换参数</param>
        void setTrans(GridTransform trans){this->_trans=trans;}

        /// <summary>
        /// 设置行数
        /// </summary>
        /// <param name="size">行数</param>
        void setSize(int size);

        /// <summary>
        /// 设置无效值
        /// </summary>
        /// <param name="noDataValue">无效值</param>
        void setNoValue(double noDataValue){this->_noValue=noDataValue;}

        /// <summary>
        /// 设置波段数
        /// </summary>
        /// <param name="bandCount">波段数</param>
        void setBandCount(int bandCount);

    };

_NNU_DGGS_END